<?php
namespace Home\Controller;

use Utuo\ForegroundController;

class FeedbackController extends ForegroundController {
	
	public function _init() {
		layout(false);
		$this->setModelName("Site");
	}
	
	/**
	 * 提问表单
	 */
	public function showAction() {
		C("TOKEN_ON", true);
		$this->display("Site/feedbackShow");
	}
	
	/**
	 * 表单提交
	 */
	public function saveAction() {
		C("TOKEN_ON", true);
		$m = M("Feedback");
		if($m->create()) {
			$m->open_id = $this->open_id;
			$m->create_time = time();
			$m->cid = $this->cid;
			false !== $m->add() and $this->ajaxSuccess('提问成功,我们会尽快回复.');
		}
		$this->ajaxError($m->getError());
	}
	
	public function feedbackListAction() {
		$openId = I('open_id', "");
		$feedbackLists = M("Feedback")->where("open_id='%s'", $openId)->limit(15)->order("id desc")->page(1)->select();
		$this->assign("feedbackLists", $feedbackLists);
		$this->display("Site/feedbackList");
	}
	
}